package org.example.juc.sync.v9;

import java.util.concurrent.TimeUnit;

/**
 * Copyright (C), 2022, szw
 * FileName: SynchronizedTestV9
 *
 * @author songyafei
 * Date:     2022/1/25 9:44
 * Description: 版本9
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
public class SynchronizedTestV9 {

    synchronized void m1() {
        System.out.println("m1 start");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        m2();
        System.out.println("m1 end");
    }

    synchronized void m2() {
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("m2");
    }

    public static void main(String[] args) {
        new SynchronizedTestV9().m1();
    }
}
